package com.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.exception.ComFoundException;
import com.mapper.*;
import com.pojo.*;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserServiceImpl  extends ServiceImpl<UserMapper, User> implements UserService {


    @Autowired
    private UserMapper userMapper;

    //登录
    @Override
    public User getUserByLogin(String userName, String password) {
        User user = userMapper.findByUserName(userName);
        //System.out.print(user.getUserName());
        if (user == null) {
            throw new ComFoundException("用户不存在");
        } else {
            String password1 = user.getPassword();
            if (!password.equals(password1)) {
                throw new ComFoundException("密码不正确");
            } else {
                return user;//登录成功
            }
        }
    }
}



